Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // 加载完成并显示时，开始计算高度
    loaded: {
      type: Boolean,
      value: false,
      observer: function (newVal, oldVal, changedPath) {

        setTimeout(() => {
          this.sizeChange()
        }, 300)
      }
    },
    title: {
      type: String,
      value: ''
    },
    maxH: {
      type: Int8Array,
      value: 152, 
      observer: function (newVal, oldVal, changedPath) {
        this.setData({
          maxH_fix: this.getPxFixed(newVal)
        })
      }
    },
    // 是否展示全部内容
    showMore: {
      type: Boolean,
      value: false
    },
    // 是否展示箭头
    showArrow: {
      type: Boolean,
      value: true
    },
    // 是否展示箭头的渐变层
    arrowShadow: {
      type: Boolean,
      value: true
    },
    // box的margin-bottom, rpx
    marginBottom: {
      type: Int8Array,
      value: 25
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    maxH_fix: {
      type: Int8Array,
      value: 224 
    },
  },

  options: {
    multipleSlots: true
  },
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show: function () {
      let that = this
      setTimeout(() => {
        that.sizeChange()
      }, 1000)
    },
    hide: function () {},
    resize: function () {},
  },

  methods: {
    _switchMore: function () {
      this.setData({
        'showMore': !this.data.showMore
      })
      
    },
    sizeChange: function () {
      this.setData({
        maxH_fix: this.getPxFixed(this.data.maxH)
      })
   

      const query = wx.createSelectorQuery().in(this)
      query.selectAll('.vbox').fields({
        size: true
      }).exec((res) => {
        
        var showArrow = res[0][0].height > this.data.maxH;
        this.setData({
          showArrow
        })
     
      })
    },
    getPxFixed(px) {
 
      return px * getApp().globalData.winWidth / 375;
    }
  }
})